package com.zhaofei.webtong;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class SpliashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_spliash);
        final Intent intent = new Intent();
        if (!getBoolean()) {
            intent.setClass(this, SplashActivity.class);
            setBoolean();
        } else {
            intent.setClass(this, MainActivity.class);
        }
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(intent);
                finish();
            }
        }, 3000);
    }

    public boolean getBoolean() {
        SharedPreferences sharedPreferences = getSharedPreferences("boolean", MODE_PRIVATE);
        boolean isTrue = sharedPreferences.getBoolean("boolean", true);
        return isTrue;
    }

    public void setBoolean() {
        SharedPreferences sharedPreferences = getSharedPreferences("boolean", MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putBoolean("boolean", false);
        editor.commit();

    }
}
